#!/bin/bash
# /**
# * Copyright (c) 2018, yzfcer@163.com
# * All rights reserved.
# * @file    fix_datatype.sh
# * @brief   替换标准的数据类型
# * @author  Jason Zhou,yzfcer@163.com
# * @version 1.0
# * @date    2021-09-15
# */

usage() {
    echo "$0 usage:"
    echo "$0 <dir>"
}

main() {
    dir=$1
    if [ x$dir == "x" ]; then
        echo "error: need dir argument"
        usage $0
        exit -1
    fi

    echo "dir: $dir"
    echo "replace.sh $dir -f \"h|c\" -S \"unsigned long long\" -r \"w_uint64_t\""
    replace.sh $dir -f "h\|c" -y -w "int8_t" -r "w_int8_t"
    replace.sh $dir -f "h\|c" -y -w "int16_t" -r "w_int16_t"
    replace.sh $dir -f "h\|c" -y -w "int32_t" -r "w_int32_t"
    replace.sh $dir -f "h\|c" -y -w "int64_t" -r "w_int64_t"
    replace.sh $dir -f "h\|c" -y -w "uint8_t" -r "w_uint8_t"
    replace.sh $dir -f "h\|c" -y -w "uint16_t" -r "w_uint16_t"
    replace.sh $dir -f "h\|c" -y -w "uint32_t" -r "w_uint32_t"
    replace.sh $dir -f "h\|c" -y -w "uint64_t" -r "w_uint64_t"

    replace.sh $dir -f "h\|c" -y -S "unsigned long long" -r "w_uint64_t"
    replace.sh $dir -f "h\|c" -y -S "long long" -r "w_int64_t"
    replace.sh $dir -f "h\|c" -y -S "unsigned long" -r "w_uint32_t"
    replace.sh $dir -f "h\|c" -y -w "long" -r "w_int32_t"
    replace.sh $dir -f "h\|c" -y -S "unsigned int" -r "w_uint32_t"
    replace.sh $dir -f "h\|c" -y -w "int" -r "w_int32_t"
    replace.sh $dir -f "h\|c" -y -S "unsigned short" -r "w_uint16_t"
    replace.sh $dir -f "h\|c" -y -w "short" -r "w_int16_t"
    replace.sh $dir -f "h\|c" -y -S "unsigned char" -r "w_uint8_t"
    replace.sh $dir -f "h\|c" -y -S "too w_int32_t" -r "too long"
    replace.sh $dir -f "h\|c" -y -w "bool" -r "w_bool_t"
}

main "$@"
